package com.sky.controller.admin;

import com.sky.constant.ShopStatus;
import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

/**
 * @version 1.0.0
 * @program:sky-take-out
 * @author: CaoYuWei
 * @create:2023-02-10 23:08:47
 **/
@RestController("adminShopController")
@RequestMapping("/admin/shop")
@Api(tags = "分类相关接口")
@Slf4j
public class ShopController {
    @Autowired
    private RedisTemplate redisTemplate;


    /**
     * 设置店铺的营业状态
     * @return
     */
    @PutMapping("/{status}")
    @ApiOperation("设置店铺的营业状态")
    public Result setStatus(@PathVariable Integer status){
        redisTemplate.opsForValue().set(ShopStatus.KEY,status);//status=1 营业     =0打烊
        return Result.success();
    }


    /**
     * 获取店铺的营业状态
     * @return
     */
    @GetMapping("/status")
    @ApiOperation("获取店铺的营业状态")
    public Result<Integer> getStatus(){
        Integer status = (Integer) redisTemplate.opsForValue().get(ShopStatus.KEY);//获取get
        return Result.success(status);
    }

}